package leetcode.Y2024M6.study;

import leetcode.Y2024M6.TreeNode;
import org.junit.Test;

public class S101 {
    public boolean isSymmetric(TreeNode root) {
        return root==null||recur(root.left,root.right);
    }
    private boolean recur(TreeNode L,TreeNode R){
        if (L==null&&R==null) return true;
        else if (L==null||R==null||L.val!=R.val) return false;
        return recur(L.left,R.right) &&recur(L.right,R.left);

    }

    @Test
    public void test(){
        int[] root={1,2,2,3,4,4,3};
        TreeNode tree = TreeNode.createTree(root);
        System.out.println(isSymmetric(tree));
    }

    @Test
    public void test1(){
        int[] root={1,2,2,-1,3,-1,3};
        TreeNode tree = TreeNode.createTree(root);
        System.out.println(isSymmetric(tree));
    }
}
